package com.llyb.chap08;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ExecutorsDemo {

    public static void main(String[] args) {
//        ExecutorService executorService = Executors.newSingleThreadExecutor();

//        ExecutorService executorService = Executors.newFixedThreadPool(3);

        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 1; i <= 10; i++) {
            Future<String> future = executorService.submit(() -> {
                System.out.println(Thread.currentThread().getName() + "  -------- come in");
                Thread.sleep(100);
                return "ok";
            });

        }

    }
}


